// 逆序对数量(归并分治)
// 给定一个长度为n的数组arr
// 如果 i < j 且 arr[i] > arr[j]
// 那么(i,j)就是一个逆序对
// 求arr中逆序对的数量
// 1 <= n <= 5 * 10^5
// 1 <= arr[i] <= 10^9
// 测试链接 : https://www.luogu.com.cn/problem/P1908
#include<iostream>
#include<vector>
using namespace std;
long long  merge(vector<int>&arr,vector<int>&tem,int left,int mid,int right)
{
    //统计
    long long ret =0;
    for(int i=left,j=mid+1;i<=mid;i++)
    {
        while(j<=right&&arr[i]<=arr[j]) j++;
        ret+=right-j+1;
    }
    int index = left;
    int begin1=left,end1=mid;
    int begin2=mid+1,end2=right;
    while(begin1<=end1&&begin2<=end2) 
    tem[index++]=arr[begin1]>=arr[begin2]?arr[begin1++]:arr[begin2++];
    while(begin1<=end1) tem[index++]=arr[begin1++];
    while(begin2<=end2) tem[index++]=arr[begin2++];
    for(int k=left;k<=right;k++) arr[k]=tem[k];
    return ret;
}
long long  solve(vector<int>&arr,vector<int>&tem,int left,int right)
{
    if(left>=right) return 0;
    int mid=(right-left)/2+left;
    return solve(arr,tem,left,mid)+solve(arr,tem,mid+1,right)+
    merge(arr,tem,left,mid,right);
}
int main()
{
    int n;
    cin>>n;
    vector<int> arr(n);
    vector<int> tem(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    cout<<solve(arr,tem,0,n-1)<<endl;
    //for(auto&ch:arr)cout<<ch<<" ";
    return 0;
}